package engine.display.newAttack.vo
{
	public class FlowVo
	{
		/**
		 *	攻击方pos点
		 */	
		public var attackPos	: int;
		
		/**
		 *	被攻击方pos点
		 */	
		public var targetPos	: int;
		
		/**
		 *	技能 
		 */	
		public var skill		: String;
		
		
		/**
		 *	伤害 
		 */	
		public var damageVos	: Vector.<DamageVo> = new Vector.<DamageVo>();
		
		/**
		 *	主角mp 
		 */		
		public var mp			: int;
		
		public var bufferhp	: int;
		
		public var buffermp	: int;
		
		/**
		 * 主角buff
		 */		
		public var buffer		: String;
		
		public var speak		: String;
		
		public var doubleHit : int = 0;
		
		public function FlowVo( pos : int, targetpos : int, skill : String, mp : int, bufferhp : int, buffermp : int, buffer : String, damageXml : XMLList = null, speak : String = "" )
		{
			this.mp			=	mp;
			this.buffer		=	buffer
			this.attackPos 	=	pos;
			this.targetPos 	=	targetpos;
			this.skill		=	skill;
			this.bufferhp	=	0;
			this.buffermp	=	buffermp;
			this.speak		=	speak;
			for each ( var xml : XML in damageXml ) 
			{
				damageVos.push( new DamageVo( xml.@damagehp, xml.@damagemp, xml.@result, xml.@hp, 
					xml.@mp, xml.@targetpos, xml.@Dead, xml.@buffer, xml.@maxhp, xml.@bufferhp ) );
			}
			
			doubleHitCount();
		}
		
		private function doubleHitCount():void
		{
			if( 1 >= damageVos.length )
			{
				return;
			}
			
			var isDoubleHit : Boolean = true;;
			var targetpos : int;
			
			if( damageVos.length > 0 )
			{
				targetpos = damageVos[ 0 ].pos;
			}
			for( var i : int = 1; i < damageVos.length; i++ )
			{
				if( damageVos[ i ].pos != targetpos )
				{
					isDoubleHit = false;
					break;
				}
			}
			
			if( isDoubleHit )
			{
				doubleHit = damageVos.length;
			}else
			{
				doubleHit = 0;
			}
		}
	}
}